/**
 * 
 */
package com.pmsco.pms.core.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.pmsco.pms.core.dao.MedicineCategoryDao;
import com.pmsco.pms.core.domain.MedicineCategory;

/**
 * @author Long Tran
 *
 */
public class MedicineCategoryDaoImpl extends HibernateDaoSupport implements MedicineCategoryDao {

	public void saveOrUpdateMedicineCategory(MedicineCategory medicineCategory) {
		getHibernateTemplate().merge(medicineCategory);
		getHibernateTemplate().flush();
	}

	public List<MedicineCategory> listMedicineCategory(MedicineCategory searchTemplate) {
		List<MedicineCategory> ret = new ArrayList<MedicineCategory>();
		ret = getHibernateTemplate().findByExample(searchTemplate);
		return ret;
	}

	public MedicineCategory loadMedicineCategory(MedicineCategory searchTemplate) {
		MedicineCategory ret = null;
		List<MedicineCategory> temp = new ArrayList<MedicineCategory>();
		temp = getHibernateTemplate().findByExample(searchTemplate);
		if(temp != null && temp.size() == 1)
			ret = temp.get(0);
		return ret;
	}

}
